#!/bin/bash
API_SERVER_ADDRESS="$1"
TOKEN="$2"
CERT_HASH="$3"
if [[ ! ${API_SERVER_ADDRESS} ]]; then
  echo "ENTER API_SERVER_ADDRESS eg:192.168.100.50:6433"
  exit 1
fi

if [[ ! ${TOKEN} ]]; then
  echo "ENTER TOKEN eg:wzvb5f.ks78pw1vx8343uze"
  exit 1
fi

if [[ ! ${CERT_HASH} ]]; then
  echo "ENTER CERT_HASH eg:sha256:f5f2ff2e4c22dba97f1c1d8a5c30b3e9bffedd55e639372e499b24ee01007602"
  exit 1
fi

kubeadm join ${API_SERVER_ADDRESS} --token ${TOKEN} \
    --discovery-token-ca-cert-hash ${CERT_HASH}
